package com.itheima.health.dao;

import com.github.pagehelper.Page;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.Setmeal;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface SetMealMapper extends Mapper<Setmeal> {

    @Select("SELECT COUNT(t1.id) as value, t2.name FROM  t_order t1 JOIN t_setmeal t2 ON t1.setmeal_id = t2.id GROUP BY t1.setmeal_id")
    List<Map<String, Object>> getSetmealReport();

    @Select("select t.name,count(*) setmeal_count,count(*)/(select count(*) from t_order) as proportion\n" +
            "        from t_order o, t_setmeal t\n" +
            "        WHERE o.setmeal_id = t.id\n" +
            "        group by t.name\n" +
            "        order by setmeal_count desc\n" +
            "        limit 0,4")
    List<Map<String,Object>> findHotSetmeal();


}
